﻿using Stardust.Common.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace Stardust.Server
{
    public sealed class ServiceRouteHttpModule : IHttpModule
    {
        public void Dispose()
        {
        }

        public void Init(HttpApplication context)
        {
            context.PostMapRequestHandler += Context_PostMapRequestHandler;
        }

        private void Context_PostMapRequestHandler(object sender, EventArgs e)
        {
            HttpContext context = ((HttpApplication)sender).Context;
            if (context.Request.RawUrl.StartsWith(StardustServer.StardustRoot, StringComparison.OrdinalIgnoreCase))
            {
                context.Handler = StardustHttpHandler.Instance;
            }
        }
    }
}
